﻿@model List<PessMvc.Models.ExpertJudgeModel>

@{
    ViewBag.Title = "ChooseExperts";
}

@{
    var grid = new WebGrid(Model,rowsPerPage:50);
}

<div id="m-title">
    <h2>挑选评委</h2>
    <div id="m-op">
        @using (Html.BeginForm("ExportToExcel2", "ExpertJudge", FormMethod.Post))
        {
            @Html.Hidden("ActivityID")
            <input type="submit" value="下载评委名单Excel" class="u-btn f-btn-long2" />
        @*@Html.ActionLink("返回评委组列表", "Details", "ExpertGroup", new { id = Model.ID }, new { @class="f-btn-long"})*@
        }
    </div>
</div>
@using (Html.BeginForm("ChooseExperts", "ExpertJudge",FormMethod.Get))
{
    @Html.Hidden("ExpertGroupID", (int)ViewBag.ExpertGroupID)
    @Html.Label("关键词：") @Html.TextBox("keyword")
    <input type="submit" value="筛选" class="u-btn f-btn-mt" /> 
}
@using (Html.BeginForm("ChooseExpertsConfirmed", "ExpertJudge", FormMethod.Post))
{
    @Html.Hidden("ExpertGroupID", (int)ViewBag.ExpertGroupID)
    @grid.GetHtml(columns: grid.Columns(
        grid.Column(header: "□", style: "u-chk-th", format: @<text><input name="expertSN" type="checkbox" value="@item.SerialNumber" /></text>),
        grid.Column("SerialNumber", header: "评委编号", style:"col1"),
        grid.Column("RealName", header: "真实姓名", style:"col2"),
        grid.Column("Gender", header: "性别", style:"col3", format: @<text>@Utility.TranslateGender(item.Gender)</text>),
        grid.Column("Birthdate", header: "出生年月", style:"col4"),
        grid.Column("Phone", header: "电话", style:"col5"),
        grid.Column("ContactAddress", header: "通讯地址", style:"col5"),
        grid.Column("ZipCode", header: "邮政编码", style:"col5")
    ))
    <input type="submit" value="选择" class="u-btn f-btn-mt" /> 
}

<script language="javascript">
    function chk_select() {
        for (i = 0; i < document.getElementsByClassName("u-chk-th").length; i++) {
            if (document.getElementsByTagName("table")[0].getElementsByTagName("th")[0].getElementsByTagName("input")[0].checked) {
                document.getElementsByClassName("u-chk-th")[i].getElementsByTagName("input")[0].checked = true;
            } else {
                document.getElementsByClassName("u-chk-th")[i].getElementsByTagName("input")[0].checked = false;
            }
        }
    }
    function chk_click() {
        tmp = 0;
        for (i = 0; i < document.getElementsByClassName("u-chk-th").length; i++) {
            if (document.getElementsByClassName("u-chk-th")[i].getElementsByTagName("input")[0].checked) {
                tmp++
            }
        }
        if (tmp == document.getElementsByClassName("u-chk-th").length) {
            document.getElementsByTagName("table")[0].getElementsByTagName("th")[0].getElementsByTagName("input")[0].checked = true;
        }
        else {
            if (tmp == 0) {
                document.getElementsByTagName("table")[0].getElementsByTagName("th")[0].getElementsByTagName("input")[0].checked = false;
            }
        }
    }
    document.getElementsByTagName("table")[0].getElementsByTagName("th")[0].onclick = chk_select;
    document.getElementsByTagName("table")[0].getElementsByTagName("th")[0].innerHTML = "<input type='checkbox' name='fly-chk' id='fly-chk'>";//"选中/取消选中";
    for (j = 0; j < document.getElementsByClassName("u-chk-th").length; j++) {
        document.getElementsByClassName("u-chk-th")[j].getElementsByTagName("input")[0].onclick = chk_click;
    }
</script>